const person = {
  name: 'tom',
  // sayHi: function(){
  //   console.log(`hi, my name is ${this.name}`) // tom,this默认绑定person对象
  // },
  sayHi: ()=>{
    console.log(`hi, my name is ${this.name}`) // undefind,箭头函数this指向sayHi
  },
  sayHiAsync: function(){
    // 异步函数中this指向会指向全局作用域s，必须在当前作用域进行保存
    // const _self = this
    // setTimeout(function(){
    //   console.log(_self.name) // tom,
    // })

    //箭头函数正常输出？
    setTimeout(()=>{
      console.log(this.name) //tom
    })
  }
}
//person.sayHi()
person.sayHiAsync()